package com.yyk.yykywd.mvvm.view_model

import androidx.lifecycle.MutableLiveData
import com.yyk.yykywd.AGENT
import com.yyk.yykywd.mvvm.entity.FullContractBean
import com.yyk.yykywd.mvvm.entity.SearchBean
import com.yyk.yykywd.mvvm.model.ReturnMoneyModel
import com.yyk.yykywd.mvvm.model.SearchModel
import java.util.ArrayList

/**
 * 文件描述：
 * Created by guo on 2019-12-06.
 */
class SearchViewModel : BaseViewModel() {
    var type: String = AGENT
    var searchs: MutableList<SearchBean.Data> = ArrayList()
    //LiveData,使该数据可以被感知
    var mSearch = MutableLiveData<SearchBean>()

    private val searchModel: SearchModel = SearchModel()

    fun search(name:String){
        searchModel.search(type,name,page.toString(),num.toString(), object : SearchModel.GetSearch {
            override fun getInfo(info: SearchBean) {
                info.data?.let { searchs.addAll(it) }
                mSearch.value = info
            }

            override fun onError(e: String) {
            }

        })
    }
}